package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetMealMapper {
    @Select("select * from setmeal where category_id=#{id}")
    List<Setmeal> chaxun(Long id);

    //向套餐表中插入数据
    @AutoFill(value = OperationType.INSERT)
    void insert(Setmeal setmeal);

    //套餐分页查询
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    //删除套餐
    @Delete("delete from setmeal where id=#{id} ")
    void deleteById(Long id);

    //根据套餐表主键id查询套餐
    @Select("select * from setmeal where id=#{id}")
    Setmeal list(Long id);

    //更新修改套餐信息
    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    //根据分类id查询套餐
    @Select("select * from setmeal where category_id=#{categoryId}")
    List<Setmeal> listByCategoryId(Long categoryId);
    //根据套餐id查询包含的菜品
    @Select("select * from setmeal_dish where setmeal_id=#{setmealId}")
    List<SetmealDish> listDishBySetmealId(Long setmealId);
}
